Walkthrough 3-2: Use the mocking service to test an API
In this walkthrough, you test the API using the Anypoint Platform mocking service. You will:
· Turn on the mocking service.
· Use the API console to make calls to a mocked API.
Starting file
If you did not complete the previous walkthrough, you can get a starting file here. This file is also located in the solutions folder of the student files ZIP located in the Course Resources.
Turn on the mocking service
1. Return to API Designer.
2. Locate the Mocking service slider in the menu bar at the top of the API console.
3. Click the right side of the slider to turn it on.
4. Look at the baseUri added to the RAML definition in the editor.
Test the /flights:get resource
5. In API console, click the Back to docs button.
6. Click the Try it button for the flights GET method then click the Send button; you should get a 200 status code and an empty response.
7. Select the Show optional parameters checkbox.
8. In the destination drop-down menu, select SFO and click Send; you should get the same response.
Test the /flights/{ID} resource
9. Click the menu button located in the upper-left of the API console and select Summary to return to the resource list.
10. Click the GET method for the /{ID} nested resource.
11. Click Try it; you should see a message that the Request URL is invalid.
12. In the ID text box, enter a value of 10.
13. Click the Send button.
14. Look at the response; you should get the same 200 status code and an empty response.
Test the /flights:post resource
15. Use the menu button located in the upper-left of the API console to return to the resource list.
16. Click the POST method.
17. Click the Try it button then click the Send button.
18. Look at the response; you should get the same generic 200 status code response.